<?php
/*
+--------------------------------------------------------------------------
|   phpBIZbiz v 2.0 full version
|   ========================================
|   by taft@wjl.cn
|   http://www.phpbiz.cn
|   all rights reserved
+---------------------------------------------------------------------------
|
|   > 
|   > 最后修改日期：2005-9-9
|   > 
|
+--------------------------------------------------------------------------
*/
!class_exists('Debug') && exit('Forbidden');
$minutes = 0.5*60;
$cache_file=ROOT_PATH.'cache/index_cache.php';
if(time()-@filemtime($cache_file) > $minutes*60)
{
	$BIZ -> pool_refresh();
	$bizcache="\$_BIZ=array(\r\n";
	$bizcache.="'index_shop'=>".$cache->DB_Cache("SELECT bs.shop_id,bs.shop_name,bi.pic_name FROM biz_order_pool as bp, biz_shop as bs,biz_pic as bi WHERE bp.type=".$POSTER[index_shop][type]." AND bp.active =1 AND bs.shop_id=bp.shop_id AND bi.pic_id=bs.shop_prime_picture_id ORDER BY bp.order_time DESC LIMIT ".$POSTER[index_shop][num]).",\r\n\r\n";

	$bizcache.="'index_goods'=>".$cache->DB_Cache("SELECT  bg.goods_id,bg.goods_name,bg.goods_price,bp.pic_name FROM biz_order_pool AS bop, biz_goods AS bg ,biz_pic AS bp WHERE bop.type=".$POSTER[index_goods][type]." AND bop.active =1 AND bop.goods_id=bg.goods_id AND bp.pic_id=bg.goods_prime_picture_id  ORDER BY bop.order_time DESC LIMIT ".$POSTER[index_goods][num]).",\r\n\r\n";
	
	$bizcache.="'second_shop'=>".$cache->DB_Cache("SELECT bs.shop_id,bs.shop_name,bi.pic_name FROM biz_order_pool as bp, biz_shop as bs,biz_pic as bi WHERE bp.type=".$POSTER[second_shop][type]." AND bp.active =1 AND bs.shop_id=bp.shop_id AND bi.pic_id=bs.shop_prime_picture_id ORDER BY bp.order_time DESC LIMIT ".$POSTER[second_shop][num]).",\r\n\r\n";
	
	$bizcache.="'broad_info'=>".$cache->DB_Cache("SELECT id,info_title FROM biz_info WHERE info_type =".INFO_BRD." ORDER BY info_active_time DESC LIMIT 0,10").",\r\n\r\n";
	
	$bizcache.="'shop_cat'=>".$cache->DB_Cache("SELECT shop_cat_id,shop_cat_name FROM  biz_shop_cat WHERE nav=1 LIMIT 2").",\r\n\r\n";
	$bizcache.=");\r\n";
	$cache->write_cache($cache_file,"<?php\r\n$bizcache?>");// 写php cache文件
}
include $cache_file;
$cache_file = ROOT_PATH.'cache/level_cache.php';
include $cache_file;
foreach( $_BIZ[index_goods] as $key=>$v )
{
	 $_BIZ['index_goods'][$key][3] = $BIZ -> get_thumb($_BIZ['index_goods'][$key][3]);
	 $_BIZ['index_goods'][$key][1]=substrs($_BIZ['index_goods'][$key]['1'],15);
}
foreach( $_BIZ['index_shop'] as $key =>$v)
{ 
	$_BIZ['index_shop'][$key][2] = $BIZ ->make_full_path($_BIZ['index_shop'][$key][2]);
  	$_BIZ['index_shop'][$key][1]=substrs($_BIZ['index_shop'][$key]['1'],15);
}
foreach( $_BIZ['second_shop'] as $key =>$v)
{
	$_BIZ['second_shop'][$key][2] = $BIZ ->get_thumb($_BIZ['second_shop'][$key][2]);
}
$pad = array("0","0");
$_BIZ['index_shop']=array_pad($_BIZ['index_shop'],$POSTER[index_shop][num],$pad);
$_BIZ['index_goods']=array_pad($_BIZ['index_goods'],$POSTER[index_goods][num],$pad);
$_BIZ['second_shop']=array_pad($_BIZ['second_shop'],$POSTER[second_shop][num],$pad);
$_BIZ['index_shop']['1']=substrs($_BIZ['index_shop']['1'],25);
$BIZ -> assign("index_shop",$_BIZ['index_shop']);

for($i=0;$i<6;$i++)
{	
	$index_goods[] = $_BIZ['index_goods'][$i];
	$index_goods2[] = $_BIZ['index_goods'][$i+6];
}

$BIZ -> assign("index_goods",$index_goods);
$BIZ -> assign("index_goods2",$index_goods2);

$BIZ -> assign("second_shop",$_BIZ['second_shop']);
$BIZ -> assign("brd_info",$_BIZ['broad_info']);
$BIZ -> assign("shop_cat",$_BIZ['shop_cat']);

//---------------
//hot search word
//---------------

$hotsearch_array = explode('|',$CONF['hotsearch']);
$word = "<font color=red>HOT!&nbsp;</font>";
$Num_hotsearch = count($hotsearch_array);
for ($i=0 ; $i<$Num_hotsearch ; $i++)
{
	if ($hotsearch_array[$i]!='')
		$word .= "<a href=\"index.php?act=Search&code=dosearch&goods_name=".rawurlencode($hotsearch_array[$i])."\" class='contentgrey'>".$hotsearch_array[$i]."</a>&nbsp";
}

$BIZ -> assign("hot",$word);
//----------------
//read advertise
//----------------
$DB -> db_query(" (SELECT id,info_title,info_type  FROM biz_info WHERE info_type =".INFO_ADV." ORDER BY info_active_time DESC LIMIT 10 ) UNION (SELECT id,info_title,info_type  FROM biz_info WHERE info_type =".INFO_REQ." ORDER BY info_active_time DESC LIMIT 10)");
while($rs = $DB -> db_fetch_row() )
{
	if( $rs['info_type']== INFO_ADV) $ad[] = array($rs[id],$rs[info_title]);
	if( $rs['info_type']== INFO_REQ) $rq[] = array($rs[id],$rs[info_title]);
}
$BIZ -> assign("ad",$ad);
$BIZ -> assign("rq",$rq);

//require ROOT_PATH."cache/diamond.php";
		//require ROOT_PATH."cache/trust.php";
		//read diamond shop by yejun shop_set_top==1 为钻石 2为诚信
		$DB -> db_query( "SELECT s . * , p.pic_name AS pn FROM biz_shop s, biz_pic p WHERE p.pic_id = s.shop_prime_picture_id  AND s.shop_check_status ='checked' AND s.shop_ban_status ='off' AND shop_set_top = ".DIAMOND_SHOP." ORDER BY s.shop_global_recommend DESC LIMIT 0 , 8 " );

		$aDiamond = array();
		
		while( $d = $DB -> db_fetch_row() )
		{
 			$aDiamond[] = array($d['shop_id'],$d['shop_name'],$BIZ->get_thumb($d['pn']));
		}
		$BIZ -> assign("aDiamond",$aDiamond);
//---------------------------------------
//load level management
//---------------------------------------
   $cache_file= ROOT_PATH."cache/level_cache.php";
   if(!file_exists($cache_file)) require ROOT_PATH."source/Cache/level_inc.php";
   require $cache_file;
//---------------------------------------
//load fee management
//---------------------------------------
   $cache_file= ROOT_PATH."cache/fee_cache.php";
   if(!file_exists($cache_file)) require ROOT_PATH."source/Cache/fee_inc.php";
   require $cache_file;
//--------------------------------------
//load reputate management
//--------------------------------------
   $cache_file= ROOT_PATH."cache/repute_cache.php";
   if(!file_exists($cache_file)) require ROOT_PATH."source/Cache/repute_cache.php";
   require $cache_file;
?>